package com.twotwoshop.service.chat.controller;

import com.twotwoshop.domin.chat.dtos.ChatMessageDto;
import com.twotwoshop.domin.common.dtos.ResponseResult;
import com.twotwoshop.service.chat.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/chat")
public class ChatController {
    
    @Autowired
    private ChatService chatService;


    /**
     * 获取聊天记录历史
     * @param chatMessageDto
     * @return
     */
    @PostMapping("/history")
    public ResponseResult getHistoryMessages(@RequestBody ChatMessageDto chatMessageDto) {

        return chatService.getHistoryMessages(chatMessageDto);
    }



    /**
     * 获取聊天列表
     * @param
     * @return
     */
    @GetMapping("/session/list")
    public ResponseResult getMessagesList() {

        return chatService.getMessagesList();
    }


    /**
     * 获取收到的未读消息数量
     * @param
     * @return
     */
    @GetMapping("/unread/count")
    public ResponseResult getMessagesCountList() {

        return chatService.getMessagesCountList();
    }


    /**
     * 删除某一条聊天
     * @param
     * @return
     */
    @PostMapping("/session/delete")
    public ResponseResult removeMessages(@RequestBody ChatMessageDto chatMessageDto) {

        return chatService.removeMessages(chatMessageDto);
    }

}